package com.baturu.vin.benz.cleanData.dao;

import com.baturu.vin.benz.dto.BenzDealInfoDTO;
import com.baturu.vin.benz.dto.BenzVinFinInfoDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 处理各种信息DTO(比如车型)
 * @author jiangxinlei
 * @Time 2017/11/13.
 */
public interface BenzDealInfoDAO {

    @Select({"select distinct class as classNo, sacode, type, a_date as adate, a_desc as adesc from sa_codes2_v_newdata"})
    List<BenzDealInfoDTO> queryAllSaDescription();

    @Results(value = {
            @Result(column = "chass_ident", property = "chassIdent"),
            @Result(column = "vinwhc", property = "vinwhc"),
            @Result(column = "whc", property = "whc"),
            @Result(column = "vin", property = "vin"),
            @Result(column = "location", property = "location"),
            @Result(column = "vin8", property = "vin8")
    })
    @Select("select id,whc,chassbm,chass_ident,vinwhc,vin,location,vin8 from dc_map_v where id>=#{id} and id< #{endId}")
    List<BenzVinFinInfoDTO> findVinFinInfoById(@Param("id") int id, @Param("endId") int endId);

    @Insert({"<script>insert ignore into tmp_benz_btr_dis_trans(btrId, displacement, transmission) values",
            "<foreach item='item' collection='btrInfo' index='index' open='' separator=',' close=''>",
            "(#{item.btrId}, #{item.displacementDesc}, #{item.transmissionDesc})",
            "</foreach>",
            "</script>"})
    int addBtrDisTrans(@Param("btrInfo") Set<BenzDealInfoDTO> btrInfo);

    @Select({"select distinct btrId, engineInfo from tmp_20180206"})
    List<Map<String, String>> queryUndealCarType();

    @Update("update tmp_20180206 set displacement=#{displacement} where btrId = #{btrId}")
    int updateUndeal(@Param("btrId") String btrId,
                     @Param("displacement") String displacement);

}
